﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Fast.Extensions.DatabaseAccessor.EntityFrameworkCore
{
    /// <summary>
    /// Sql 操作仓储接口
    /// </summary>
    public interface ISqlRepository : ISqlRepository<DefaultDbContextLocator>,
        ISqlReaderRepository, ISqlExecutableRepository
    {

    }
    /// <summary>
    /// Sql 操作仓储接口
    /// </summary>
    public interface ISqlRepository<TDbContextLocator> : IRootSqlRepository,
        ISqlReaderRepository<TDbContextLocator>,
        ISqlExecutableRepository<TDbContextLocator>
        where TDbContextLocator : class, IDbContextLocator
    {

    }
    /// <summary>
    /// Sql 操作仓储接口
    /// </summary>
    public interface IRootSqlRepository : IRootSqlReaderRepository, IRootSqlExecutableRepository
    {
        /// <summary>
        /// 数据库操作对象
        /// </summary>
        DatabaseFacade Database { get; }

        /// <summary>
        /// 数据库上下文
        /// </summary>
        DbContext Context { get; }

        /// <summary>
        /// 切换仓储
        /// </summary>
        /// <typeparam name="TChangeDbContextLocator">数据库上下文定位器</typeparam>
        /// <returns>仓储</returns>
        ISqlRepository<TChangeDbContextLocator> Change<TChangeDbContextLocator>()
            where TChangeDbContextLocator : class, IDbContextLocator;
    }
}
